﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Luna;

namespace TextDataExtractor.DEML {
	
	public class ForEachAction : CompositeAction {

		public override void execute(ExecutionContext context) {
			AbstractPattern pattern = context.ActivePattern;
			string patName = getArgument("from");
			if (pattern != null && patName.isNotNullAndEmpty())
				foreach (var p in pattern.getMatchedPatterns(pat => pat.Name.Equals(patName))) {
					context[patName] = p;
					base.execute(context);
				}
		}
	}
}
